package Q3;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt(); //n 个字符串
        int m = scanner.nextInt(); //每个字符串长为 m

        char[][] ch = new char[n][m];

        for (int i = 0; i < n; i++) {
            String str = scanner.next();
            for (int j = 0; j < m; j++) {
                ch[i][j] = str.charAt(j);
            }
        }

        int[][] dp = new int[n + 1][m + 1];

        for (int i = 1; i < n + 1; i++) {
            for (int j = 1; j < m + 1; j++) {
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + grade(ch[i - 1][j - 1]);
            }
        }

        System.out.println(dp[n][m]);
    }

    public static int grade(char ch) {
        switch (ch) {
            case 'l':
                return 4;
            case 'o':
                return 3;
            case 'v':
                return 2;
            case 'e':
                return 1;
            default:
                return 0;
        }
    }
}
